﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Shop
{
    public partial class CustomerServer : Form
    {
        private DataHelper dh;
        public CustomerServer()
        {
            InitializeComponent();
            dh = new DataHelper();
        }

        private void Registerbutton_Click(object sender, EventArgs e)
        {
            if (CustIDtextBox.Text!="" && FNametextBox.Text != "" && LNametextBox.Text != "" && EmailtextBox.Text != "" && BankAcctextBox.Text != ""
                && MobiletextBox.Text !="" && DofBtextBox.Text !="" && GendertextBox.Text !="" && CountrytextBox.Text !="" && CitytextBox.Text !="" && BraceletRegtextBox.Text !="")
            {
                int nrAdded = dh.AddNewCust(CustIDtextBox.Text,FNametextBox.Text,LNametextBox.Text,EmailtextBox.Text,BankAcctextBox.Text,
                    Convert.ToInt16(MobiletextBox.Text),DofBtextBox.Text,GendertextBox.Text,CountrytextBox.Text,CitytextBox.Text,BraceletRegtextBox.Text);
                if (nrAdded > 0)
                {
                    MessageBox.Show("Succesfully added to the database!","Registration",MessageBoxButtons.OK,MessageBoxIcon.Information);
                   
                }
                else
                {
                    MessageBox.Show("Error while adding products!","Regostration",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }

            }
        }

        private void Validatebutton_Click(object sender, EventArgs e)
        {
            if (TicketIDtextBox.Text !="")
            {
                if (dh.FindCustID(TicketIDtextBox.Text) == null)
                {
                    MessageBox.Show("Cannot find!!!!!");
                }
                else 
                {
                    MessageBox.Show("Info has uploaded!!!!!");
                }
                
            }
        }

    }
}
